#include "mtpMessage.h"
#include "App.h"

MtpMessage::MtpMessage(MtpProtocol* packet) : Message(packet)
{

}

MtpMessage::~MtpMessage()
{
}

void MtpMessage::decodeBody()
{
	MtpProtocol* packet = (MtpProtocol*)getPacket();
	if (packet) {
		jsonContent = packet->jsonContent();
	}
}

void MtpMessage::encodeBody()
{
	if (!jsonContent.empty()) {
		MtpProtocol* packet = (MtpProtocol*)getPacket();
		if (!packet) {
			return;
		}
		packet->setUtf8JsonContent();
		packet->setBody(jsonContent);
	}
}

void MtpMessage::send(const IPaddress& attachment)
{
	App::inst().getUdpSender()->send(this, attachment);
}
